package com.ddone.service.impl;

import com.ddone.bean.User;
import com.ddone.dao.UserMapper;
import com.ddone.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ddone
 * @date 2024/3/25-16:52
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return userMapper.selectAll();
    }

    @Override
    public User findUserById(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void save(User user) {
        // 支持动态SQL
        userMapper.insertSelective(user);
    }

    @Override
    public void update(User user) {
        // 支持动态SQL
        userMapper.updateByPrimaryKeySelective(user);

    }

    @Override
    public void delete(Integer id) {
        userMapper.deleteByPrimaryKey(id);
    }
}
